<?php

/**
 * verwaltung actions.
 *
 * @package    adminslittlehelper
 * @subpackage verwaltung
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 2692 2006-11-15 21:03:55Z fabien $
 */
class updateLocationAction extends sfAction
{
  /**
   * Executes index action
   *
   */
  public function execute()
  {
    if (!$this->getRequestParameter('id'))
    {
      $location = new Standort();
    }
    else
    {
      $location = StandortPeer::retrieveByPk($this->getRequestParameter('id'));
      $this->forward404Unless($location);
    }

    $location->setId($this->getRequestParameter('id'));
    $location->setBenutzerId(1);
    $location->setName($this->getRequestParameter('name'));
    if ($this->getRequestParameter('updated_on'))
    {
      list($d, $m, $y) = sfI18N::getDateForCulture($this->getRequestParameter('updated_on'), $this->getUser()->getCulture());
      $location->setUpdatedOn("$y-$m-$d");
    }

    $location->save();
    bwUtils::saveAddFields($location);
    $this->setFlash('errMessage', 'Daten erfolgreich gespeichert.');
    
    return $this->redirect('management/showOverview?id='.$location->getId());
  }
}
